package com.wwwc.index.web.servlet;

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.ServletRequestWrapper;
import java.net.*;

import com.wwwc.util.web.*;
import com.wwwc.index.web.ejb.database.*;
//import com.wwwc.index.web.database.*;
import com.wwwc.index.web.ejb.*;

import org.xml.sax.*;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.SAXException; 
import java.util.Properties;

// by extends DefaultHandler, you do not need list all methods
public class XmlValueParser extends DefaultHandler {

    private StringBuffer error = new StringBuffer();

    //===========================================================
    // SAX DocumentHandler methods
    //===========================================================

    public void setDocumentLocator(Locator l) 
    {
        try {
	    error.append("documentLocator="+l.getSystemId() );
        } catch (Exception e) {
	    error.append("setDocument:Error["+e+"]");   
        }
    }

    StringBuffer sbf2 = new StringBuffer();

    public void startElement(String uri, String s_name, String q_name, Attributes attrs) {
	try {
	    sbf2.append("\ns_name"+s_name+"\nq_name="+q_name);
	}
	catch (Exception e){
	    error.append("startElement:Error["+e+"]");   
	}
    }

    StringBuffer sbf3 = new StringBuffer();

    public void characters(char[] ch, int start, int length) {
	try {
	    sbf3.append(ch, start, length);
	}
	catch(Exception e){ 
	    error.append("characters:Error:["+e+"]");
	}
    }

    StringBuffer sbf4 = new StringBuffer();

    public void endElement(String uri, String s_name, String q_name) {
	try {	    
	    sbf4.append("\ns_name="+s_name+"\nq_name="+q_name);
	}
	catch(Exception e){ 
	    error.append("endElement:Error:["+e+"]");
	}
    }

    public void printout() {
	System.out.println("sbf4="+sbf4);
	System.out.println("sbf2="+sbf2);
	System.out.println("sbf3="+sbf3);
	System.out.println("error="+error);
    }
}





